package com.yonyou.iuap.controller.app;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yonyou.iuap.pub.JsonUtils;
import com.yonyou.iuap.shell.pub.RequestDto;
import com.yonyou.iuap.shell.pub.ResultDto;
import com.yonyou.iuap.shell.service.intf.IKmPublishService;

/**
 * 查询最新知识和最热知识
 * **/
@Controller
@RequestMapping(value="publish")
public class KmPublishEntityController {
	private final Logger logger = (Logger) LoggerFactory.getLogger(getClass());
	private long start,end;
	@Autowired
	private IKmPublishService kmPublishServiceImpl;
	@RequestMapping(value="/App/querypublish",method=RequestMethod.POST)
	@ResponseBody
	public String selectpublishasc(@RequestBody Map parMap,HttpServletRequest request,HttpServletResponse response){
		start=System.currentTimeMillis();
		StringBuffer str=new StringBuffer();
		str.append(" 1=1 ");
		RequestDto req = new RequestDto();
		int pageNum = parMap.get("pageNum")==null?0:Integer.valueOf(parMap.get("pageNum").toString())-1;
		int pageSize = parMap.get("pageSize")==null?15:Integer.valueOf(parMap.get("pageSize").toString());
		req.setPageNum(pageNum);
		req.setPageSize(pageSize);
		req.setParams(str.toString());
		ResultDto resDto = kmPublishServiceImpl.selectpublishtimeasc(req);
		end=System.currentTimeMillis();
		logger.info("querypublish接口调用时间"+String.valueOf(end-start));
		return JsonUtils.toJsonStr(resDto);
	}
	
	
	@RequestMapping(value="/App/querypublishfovorite",method=RequestMethod.POST)
	@ResponseBody
	public String querypublishfovorite(@RequestBody Map parMap,HttpServletRequest request,HttpServletResponse response){
		start=System.currentTimeMillis();
		ResultDto resDto = kmPublishServiceImpl.queryKmpublishfavoarite();
		end=System.currentTimeMillis();
		logger.info("querypublish接口调用时间"+String.valueOf(end-start));
		return JsonUtils.toJsonStr(resDto);
	}
	
	
	
}
